<!--
 * @Author: 毕晨曦 
 * @Date: 2024-07-29 23:09:32
 * @LastEditors: 毕晨曦 
 * @LastEditTime: 2024-07-29 23:09:39
 * @FilePath: /xing-fu-da-zi-weapp/src/components/loading/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view class="loading-box" :style="loadingStyle">
    <view class="rotate iconfont icon-loading" :style="icontStyle"></view>
    <slot></slot>
  </view>
</template>

<script>
import { computed } from "vue";
export default {
  data() {
    return {};
  },
  props: {
    size: {
      type: Number,
      default: 100,
    },
    mask: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    icontStyle() {
      return `font-size:${this.size}rpx`;
    },
    loadingStyle() {
      return this.mask ? "background: rgba(0, 0, 0, 0.3);" : "";
    },
  },
};
</script>

<style lang="scss" scoped>
.loading-box {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.rotate {
  animation: rotate 2s ease-in-out infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}
</style>
